<!--综合管理-->
<template>
  <div class="m-view-masterMenu m-window">
    <div class="m-module" v-for="(item, index) in menu" :key="index">
      <div class="m-title">{{ item.name }}</div>
      <ul>
        <li
          v-for="(list, serial) in item.children"
          :key="serial"
          @click="addTab(list)"
          :class="{ 'm-completed': list.completed }"
        >
          <i :class="'iconfont icon-' + list.code"></i>
          <span>{{ list.cName }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import utils from "@/public/utils";
import authorize from "@/public/authorize";

export default {
  data() {
    return {
      menu: [
        {
          title: "基础数据",
          list: [
            {
              cName: "公司节假日设置",
              name: "companyHolidaySetting",
              completed: false,
            },
            {
              cName: "公司卸货地点维护",
              name: "companyUnloadingLocation",
              completed: false,
            },
            {
              cName: "公司预约时段维护",
              name: "companyAppointTime",
              completed: false,
            },
            {
              cName: "公司卸货仓管员维护",
              name: "companyUnloadingWarehouseKeeper",
              completed: false,
            },
          ],
        },
        {
          title: "预约列表",
          list: [
            {
              cName: "预约列表",
              name: "appointmentList",
              completed: false,
            },
          ],
        },
      ],
      routerList: [
        {
          cName: "公司节假日设置",
          name: "companyHolidaySetting",
          completed: false,
        },
        {
          cName: "公司卸货地点维护",
          name: "companyUnloadingLocation",
          completed: false,
        },
        {
          cName: "公司预约时段维护",
          name: "companyAppointTime",
          completed: false,
        },
        {
          cName: "公司卸货仓管员维护",
          name: "companyUnloadingWarehouseKeeper",
          completed: false,
        },
        {
          cName: "预约列表",
          name: "appointmentList",
          completed: false,
        },
      ],
    };
  },
  props: {
    addTab: {
      type: Function,
    },
  },
  methods: {
    getMenuDetails() {
      //console.log("获取子菜单");
      var menuId = utils.getMenuId("menuId"); // 菜单ID   6598
      var auth = utils.getSession("auth");

      auth.forEach((aItem) => {
        if (aItem.id == menuId) {
          this.menu = aItem.children;
        }
      });
      this.menu.forEach((bItem) => {
        bItem.children.forEach((cItem) => {
          this.routerList.forEach((dItem) => {
            if (dItem.name == cItem.code) {
              cItem.name = dItem.name;
              cItem.cName = dItem.cName;
              cItem.completed = true;
            }
          });
        });
      });
      // console.log(this.menu)
    },
  },
  components: {},
  beforeMount() {
    this.getMenuDetails();
  },
};
</script>

<style></style>
